using System;
using WIT.DAQ.Core.Enums;
using WIT.DAQ.Core.Models;

namespace WIT.DAQ.Core;

/// <summary>
/// WIT.Core的连接结构体，用于记录连接的设备、通信协议以及对应的连接实例
/// </summary>
internal struct Connection
{
	private Device _device;

	/// <summary>
	/// 设备Id
	/// </summary>
	internal Guid DeviceId { get; set; }

	/// <summary>
	/// 设备
	/// </summary>
	internal Device Device
	{
		get
		{
			if (_device == null)
			{
				_device = Common.GetDevice(DeviceId);
			}
			return _device;
		}
	}

	/// <summary>
	/// 任务Id
	/// </summary>
	internal Guid? TaskId { get; set; }

	/// <summary>
	/// 通信协议
	/// </summary>
	internal EnumProtocol Protocol { get; set; }

	/// <summary>
	/// 连接实例
	/// </summary>
	internal object ConnectionIns { get; set; }
}
